﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dt261.Base
{
    class ResultCommand
    {


        private int _db;
        private bool _isYanbi;
        private int _yanbiDB;
        private bool _isUserResp;
        private int _testToneType;
        private int _testToneTime;
        private int _markType;
        private int _yanbiType;


        //67260448

        //db = 22
        //isMasking = false
        //masking = 30
        //iSResponse = true
        //toneType = 0
        //toneCycle = 0
        //point = 1
        //maskingType = 0

        public ResultCommand()
        {

        }

        public ResultCommand(long recond)
        {
            //self = [super init];s
            //if(self)


            _db = (int)((recond & 0x00FF) - 10);
            _isYanbi = (bool)(((recond >> 8) & 0x0001) == 1);
            _yanbiDB = (int)((recond >> 9) & 0x00FF) - 10;
            _isUserResp = (bool)(((recond >> 17) & 0x0001) == 1);
            _testToneType = (int)(recond >> 18) & 0x000F;
            _testToneTime = (int)(recond >> 22) & 0x000F;
            _markType = (int)(recond >> 26) & 0x003F;
            _yanbiType = (int)(recond >> 32) & 0x000F;



            //return self;

        }

        public ResultCommand(int db, bool isYanbi, int yanbiDB, bool isUserResp, int testToneType, int testToneTime, int markType, int yanbiType)
        {
            _db = db;
            _isYanbi = isYanbi;
            _yanbiDB = yanbiDB;
            _isUserResp = isUserResp;
            _testToneType = testToneType;
            _testToneTime = testToneTime;
            _markType = markType;
            _yanbiType = yanbiType;
        }

        public long getRecord()
        {
            long res = 0;

            res = ((long)(_yanbiType & 0x000F) << 32) +
                        ((_markType & 0x003F) << 26) +
                        ((_testToneTime & 0x000F) << 22) +
                        ((_testToneType & 0x000F) << 18) +
                        (((_isUserResp ? 1 : 0) & 0x0001) << 17) +
                        (((_yanbiDB + 10) & 0x00FF) << 9) +
                        (((_isYanbi ? 1 : 0) & 0x0001) << 8) +
                        (((_db + 10) & 0x00FF));


            return res;
        }

        public override string ToString()
        {
            return base.ToString();
        }
    }
}
